show Abstracthide AbstractHow populations adapt to their environment is a fundamental question in biology. Yet we know surprisingly little about this process, especially for endangered species such as non-human great apes. Chimpanzees, our closest living relatives, are particularly interesting because they inhabit diverse habitats, from rainforest to woodland-savannah. Whether genetic adaptation facilitates such habitat diversity remains unknown, despite having wide implications for evolutionary biology and conservation. Using 828 new exomes from wild chimpanzees (388 post-filtering), we find evidence of fine-scale genetic adaptation to habitat. Notably, adaptation to malaria in chimpanzees is mediated by the same genes underlying adaptation to malaria in humans. This work demonstrates the power of non-invasive samples to reveal genetic adaptations in endangered populations and highlights the importance of adaptive genetic diversity for chimpanzees.